package chat.adapter;

import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.xkh.xkh.MyApplication;
import com.xkh.xkh.R;

import java.util.ArrayList;
import java.util.List;

import chat.dto.Rooms;

/**
 * 查找房间
 * Created by Administrator on 2016/3/29.
 */
public class SearchRoomAdapter extends BaseAdapter {

    List<Rooms> rooms = new ArrayList<Rooms>();

    public void setRooms(List<Rooms> rooms) {
        this.rooms = rooms;
    }

    @Override
    public int getCount() {
        return rooms.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        Rooms room = rooms.get(position);
        convertView = View.inflate(MyApplication.share(), R.layout.item_searchroom,null);
        TextView tv_roomName = (TextView) convertView.findViewById(R.id.id_tv_roomName);
        TextView tv_roomDesc = (TextView) convertView.findViewById(R.id.id_tv_roomDesc);
        TextView tv_roomMaxNum = (TextView) convertView.findViewById(R.id.id_tv_roomMaxNum);
        TextView tv_roomTopic = (TextView) convertView.findViewById(R.id.id_tv_roomTopic);
        TextView tv_time = (TextView) convertView.findViewById(R.id.id_tv_createTime);

        tv_roomName.setText(room.getRoom_Name());
        tv_roomDesc.setText(room.getRoom_Desc());
        tv_roomMaxNum.setText(room.getRoom_MaxNum()+"");
        tv_roomTopic.setText(room.getRoom_Topic());
        tv_time.setText(room.getRoom_CreateTime());

        convertView.setTag(R.id.id_search_room,room);
        return convertView;
    }
}
